![]() |
||||||||
Making A Brick Wall Sometimes when we're working on a project it becomes rather tough to find the forrest through the trees... in otherwords, we lose track of what we're traying to do. Let's take a gander at Brickwall. Work with your group to design an algorithm for doing brick wall (yes I know, many of us are well along on this, but bear with me) that consists of 5 to 10 steps. ═══════════════════════════ Step #0 K.I.S.S. is our friend so let's KEEP IT SIMPLE, STUPID That means divide our project up into steps, test those steps and see where we might have problems.
═══════════════════════════
Now let's work the steps: ═══════════════════════════ Step #1: Make a Brick Easy Sneezy - the brick needs to be 20 steps wide and 10 steps tall. I think I can handle that:
Note, I've physically dragged the sprite away from the square using my mouse to make the square more easily visible |
||||||||
═══════════════════════════ Step #2: Make a Row of Bricks by looping through step #1 Easy Sneezy - the brick needs to be 20 steps wide and 10 steps tall. I think I can handle that:
Notice that I'm not trying to write the whole program, start to finish. I've identified the steps I need to accomplish to make a brick wall, and now I'm making sure I can do each of those steps. Notice also I keep the "Clear" block available to wipe my screen. Notice also (also) that I know I have to start the block at the left side of the screen so I'm manually sending my cursor there with the Go To block. ═══════════════════════════ Step #3: This gets a touch trickier, since I have to start my brick building at the lower left corner of the screen; build a row of bricks, then run the code again
Notice that I'm not QUITE done here. I have some annoying diaganol lines for when the sprite finishes writing on the right hand side and moves back to start a new row (but I can dismiss with that pretty easily using the "hide" block") My blocks don't QUITE go far enough to the left, but that's no worries, I'll just extend my brick row by a bit. The FINAL part is kinda nasty... how can we offset every other row to make a nice pretty brick wall like this:
WORK O' THE DAY: Please reproduce the code in each of the 3 steps above in a new SNAP program. Title that: MRWbrickwallAnalysis Please annotate (make comments using the 'comments' option) that CLEARLY explains what I'm doing. One of the skills I'm going to teach you this semester is to READ other people's code... learning to code is great, but it's at least as important that you get used to reading, commenting and analyzing someone else's work/code. Once you are done commenting on my code, you can continue on to fix my code and turn it into a fully functional brickwall program, or you can continue writing your own code. You are free to use my code in bits and pieces to help with your own code, but please don't copy more than just a few lines here and there. |